using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;

namespace annotation_language.lib
{
    class Framework
    {
        public String framework_name { get; set; }
        public String instance_type { get; set; }
        public List<Frame> frames { get; set; }
        public List<String> awaken_lexis { get; set; }
    }
    class Frame
    {
        public String frame_name { get; set; }
        public String type { get; set; }
        public bool is_core { get; set; }
    }

    public class Framework_manager
    {
        List<Framework> frameworks;
        public Framework_manager(String framework_file_path)
        {
            String json_string = File.ReadAllText(framework_file_path);
            this.frameworks = JsonSerializer.Deserialize<List<Framework>>(json_string);
        }

        public Framework_manager(byte[] framework_file)
        {
            this.frameworks = JsonSerializer.Deserialize<List<Framework>>(framework_file);
        }

        public bool is_exist(String framework_name)
        {
            foreach (Framework framework in this.frameworks)
            {
                if (framework.framework_name == framework_name)
                {
                    return true;
                }
            }
            return false;
        }

        public bool is_exist(String framework_name, String frame_name)
        {
            foreach (Framework framework in this.frameworks)
            {
                if (framework.framework_name == framework_name)
                {
                    foreach (Frame frame in framework.frames)
                    {
                        if (frame.frame_name == frame_name)
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }

    }
}
